package grape.crm.service.customercredential.impl;

import grape.crm.service.customercredential.map.CustomerCredentialServiceMapper;
import grape.crm.service.customercredential.param.AddCustomerCredentialParam;
import grape.crm.service.customercredential.po.CustomerCredential;
import grape.crm.service.customercredential.mapper.CustomerCredentialMapper;
import grape.crm.service.customercredential.api.ICustomerCredentialService;
import grape.common.service.common.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 客户证件表 服务实现类
 * </p>
 *
 * @author yangwei
 * @since 2020-09-14
 */
@Service
public class CustomerCredentialServiceImpl extends BaseServiceImpl<CustomerCredentialMapper, CustomerCredential> implements ICustomerCredentialService {

    @Autowired
    private CustomerCredentialServiceMapper customerCredentialServiceMapper;

    @Override
    public boolean batchAddCustomerCredential(String customerId, List<AddCustomerCredentialParam> customerCredentials) {
        List<CustomerCredential> customerCredentialList = new ArrayList<>(customerCredentials.size());
        CustomerCredential customerCredential = null;
        for (AddCustomerCredentialParam customerCredentialParam : customerCredentials) {
            customerCredential = customerCredentialServiceMapper.paramToPo(customerCredentialParam);
            customerCredential.setCustomerId(customerId);
            customerCredentialList.add(customerCredential);
        }
        // 保存联系方式
        return saveBatch(customerCredentialList);
    }
}
